<template>
  <div class="form form-readonly">
    <div class="group">
      <div class="label">姓名</div>
      <div class="txt">{{ state.starinfo?.star?.name }}</div>
    </div>
    <div class="group">
      <div class="label">年龄</div>
      <div class="txt">{{ state.starinfo?.register?.age }} 岁</div>
    </div>
    <div class="group">
      <div class="label">身高</div>
      <div class="txt">{{ state.starinfo?.register?.height }}cm</div>
    </div>
    <div class="group">
      <div class="label">学校</div>
      <div class="txt">{{ state.starinfo?.register?.school }}</div>
    </div>
    <div class="group">
      <div class="label">履历</div>
      <div class="txt">{{ state.starinfo?.register?.history }}</div>
    </div>
    <div class="group">
      <div class="label">现场照片</div>
      <div class="imgs">
        <img
          v-for="(item, index) in photos"
          :key="index"
          :src="item"
          @click="imgShow"
        />
      </div>
    </div>
    <div class="group">
      <div class="label">初试编号</div>
      <div class="txt">{{ state.starinfo?.checkin1?.checkin_no }}</div>
    </div>
    <div class="group">
      <div class="label">初试结果</div>
      <div class="txt">{{ status }}</div>
    </div>
    <div class="group">
      <div class="label">初试点评</div>
      <div class="txt">
        {{ state.starinfo?.register?.prtest_say || "" }}
        <div class="tags">
          <span v-for="(item, index) in tags" :key="index">{{ item }}</span>
        </div>
      </div>
    </div>
    <div class="group">
      <div class="label">复试编号</div>
      <div class="txt">{{ state.starinfo?.checkin2?.checkin_no }}</div>
    </div>
    <div class="group">
      <div class="label">复试结果</div>
      <div class="txt">{{ result }}</div>
    </div>
  </div>
</template>

<script setup>
import ajax from "../../util/http";
import { reactive, ref, computed, getCurrentInstance } from "vue";
import { useRouter, useRoute } from "vue-router";

const router = useRouter();
const route = useRoute();

const state = reactive({
  starinfo: {},
});

const photos = computed(() => {
  if (state.starinfo?.register?.prtest_photo) {
    return state.starinfo.register.prtest_photo.split(",");
  }
});

const status = computed(() => {
  let prtest_result = state.starinfo?.register?.prtest_result;
  if (prtest_result == 1) {
    return "晋级";
  }
  if (prtest_result == 2) {
    return "待定";
  }
  if (prtest_result == 3) {
    return "--";
  }
});

const tags = computed(() => {
  if (state.starinfo?.register?.prtest_tags) {
    return state.starinfo.register.prtest_tags.split("，");
  }
});

const result = computed(() => {
  let retest_result = state.starinfo?.register?.retest_result;
  if (retest_result == 1) {
    return "进组";
  }
  if (retest_result == 2) {
    return "未进组";
  }
});

const { proxy } = getCurrentInstance();
const imgShow = (e) => {
  proxy.$popup({
    img: e.target.getAttribute("src"),
  });
};

ajax
  .post("/star/scene/star_table", { checkin_id: route.query.checkin_id })
  .then((res) => {
    if (res.code == 1) {
      state.starinfo = res.data;
    }
  });
</script>